<?php
  /**
   * GameServerInfo
   *
   * The GameServerInfo class Provides Game Servers Information
   *
   * @copyright Copyright (c) 2011, XBloks Progect
   */
    class GameServerInfo extends iJBlock implements iJSingleton{
        
        /**
         *
         * Class Constructuctor
         * @access public
         */
        public function __construct() {
    
        }
        
        
        /**
         * execute
         *
         * Executes the block to generate the tokens
         *
         * @return array Array with the tokens of the block
         *
         * @access public
         */
        public function execute() {
          $GameServer  = iJFactory::singleton('GameServer');
          $iJLanguages = iJFactory::singleton('iJLanguages');
          
          
          $page   = isset($_REQUEST['page'])                                  ? $_REQUEST['page']   : 1;
          $search = isset($_REQUEST['search']) && !empty($_REQUEST['search']) ? $_REQUEST['search'] : '';
          
          $List  = $GameServer->getGameServerChilds($page, $search, $game, $rank, $status);
          
          $games        = $List[0];
          $QGames       = $List[1];
          
          foreach($games as $key => $game) {
            $games[$key]['info'] =  iJHrefLink::linkToLocalPage('admin_game_server_info')  . '?gameID=' . $game['id'];
            
          }
          $this->addToken('servers',     $games);         
          $this->addToken('search',      $search);
          $this->addToken('page',        $page);
          $this->addToken('ranks',       $GameServer->getGameServerRanks());
          $this->addToken('games',       $GameServer->getGameServerGameTypes());
          $this->addToken('statuses',    $GameServer->getGameServerStatuses());
          

          $this->addToken('delete_icon',   iJHrefLink::Icon('trash',     '16x16'));
          $this->addToken('server_icon',   iJHrefLink::Icon('host',     '16x16'));
          $this->addToken('info_icon',     iJHrefLink::Icon('info',     '16x16'));
          
          $this->addToken('form_action', iJHrefLink::linkToLocalPage('admin_games') . '?' . iJGetAllGetParams(array('delKey'))); 
          $this->addToken('curLanguage', $iJLanguages->getLanguage());
          $this->addToken('languages',   $iJLanguages->getLanguagesExeptCurrent());  
          
          
          $get = array();
          $get['search'] = $search;
          $get['rank'] = $search;
          $get['status'] = $search;
          
          $this->addToken('total_items',    $QGames->getSize());
          $this->addToken('pages_count',    $QGames->getPagesCount());
          $this->addToken('prev_link',      $QGames->getPerviousLink($page, 'admin_config', $get));
          $this->addToken('next_link',      $QGames->getNextLink($page,     'admin_config', $get));
          return parent::execute();
          return parent::execute();
        }
        
    }
?>